package util;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 徐建林
 * @date 2018/11/3 19:46
 */
public class PageHandleUtil<T> {
    private  Integer pageNo1;
    private Integer pageSize1;
    private Integer rows1;
    private  Integer pageTotal1;
    private List<T> list1;
    private  Integer pageNo2;
    private Integer pageSize2;
    private Integer rows2;
    private  Integer pageTotal2;
    private List<T> list2;
    public PageHandleUtil(Integer pageNo1, Integer pageSize1, Integer rows1,Integer pageNo2, Integer pageSize2, Integer rows2) {

        this.pageSize1 = pageSize1;
        this.rows1 = rows1;
        //先算出总页数
        this.pageTotal1=this.rows1%this.pageSize1==0?this.rows1/this.pageSize1:(this.rows1/this.pageSize1)+1;
        //判断 pageNo 的几种情况
        if(pageNo1==null){
            this.pageNo1=1;
        }else if (pageNo1<1) {
            this.pageNo1=1;
        }else if (this.pageTotal1==0) {
            this.pageNo1=1;
        }else if (pageNo1>this.pageTotal1) {
            this.pageNo1=this.pageTotal1;
        }else {
            this.pageNo1=pageNo1;
        }

        this.pageSize2 = pageSize2;
        this.rows2 = rows2;
        //先算出总页数
        this.pageTotal2=this.rows2%this.pageSize2==0?this.rows2/this.pageSize2:(this.rows2/this.pageSize2)+1;
        //判断 pageNo 的几种情况
        if(pageNo2==null){
            this.pageNo2=1;
        }else if (pageNo2<1) {
            this.pageNo2=1;
        }else if (this.pageTotal2==0) {
            this.pageNo2=1;
        }else if (pageNo2>this.pageTotal2) {
            this.pageNo2=this.pageTotal2;
        }else {
            this.pageNo2=pageNo2;
        }


    }

    public Integer getPageNo1() {
        return pageNo1;
    }

    public void setPageNo1(Integer pageNo1) {
        this.pageNo1 = pageNo1;
    }

    public Integer getPageSize1() {
        return pageSize1;
    }

    public void setPageSize1(Integer pageSize1) {
        this.pageSize1 = pageSize1;
    }

    public Integer getRows1() {
        return rows1;
    }

    public void setRows1(Integer rows1) {
        this.rows1 = rows1;
    }

    public Integer getPageTotal1() {
        return pageTotal1;
    }

    public void setPageTotal1(Integer pageTotal1) {
        this.pageTotal1 = pageTotal1;
    }

    public List<T> getList1() {
        return list1;
    }

    public void setList1(List<T> list1) {
        this.list1 = list1;
    }

    public Integer getPageNo2() {
        return pageNo2;
    }

    public void setPageNo2(Integer pageNo2) {
        this.pageNo2 = pageNo2;
    }

    public Integer getPageSize2() {
        return pageSize2;
    }

    public void setPageSize2(Integer pageSize2) {
        this.pageSize2 = pageSize2;
    }

    public Integer getRows2() {
        return rows2;
    }

    public void setRows2(Integer rows2) {
        this.rows2 = rows2;
    }

    public Integer getPageTotal2() {
        return pageTotal2;
    }

    public void setPageTotal2(Integer pageTotal2) {
        this.pageTotal2 = pageTotal2;
    }

    public List<T> getList2() {
        return list2;
    }

    public void setList2(List<T> list2) {
        this.list2 = list2;
    }
}
